#include "../sys/arrays.h"

int main()
{
	size_t Nx = 100;
	size_t Ny = 200;
	size_t Nz = 60;
	
	size_t i,j,k;
	{
		Real *a = mds_array1d_create(Nx, sizeof(Real) );
		MDS_MEMORY();
		if( a )
		{
			for( i=0; i < Nx; ++i )
			{
				a[i] = i;
			}
			
			for( i=0; i < Nx; ++i )
			{
				if( (size_t)a[i] != i )
					fprintf(stderr, "1D I/O failure!");
			}
			
		}
		
		
		mds_array1d_delete(a, 100, sizeof(Real) );
		MDS_MEMORY();
	}
	
	{
		Real **a = (Real **)mds_array2d_create(Nx, Ny, sizeof(Real) );
		MDS_MEMORY();
		if( a )
		{
			for( i=0; i < Nx; ++i )
			{
				for( j=0; j < Ny; ++j )
				{
					a[i][j] = i+j;
				}
			}
			
			for( j=0; j < Ny; ++j )
			{
				for( i=0; i < Nx; ++i )
				{
					if( (size_t)(a[i][j]) != i+j )
					{
						fprintf( stderr, "2D I/O failure !\n");
					}
				}
			}
		}
		
		mds_array2d_delete( (void **)a, Nx, Ny, sizeof(Real) );
		MDS_MEMORY();
	}
	
	{
		int ***a = (int ***)mds_array3d_create(Nx,Ny,Nz,sizeof(int));
		MDS_MEMORY();
		if( a )
		{
			for( i=0; i < Nx; ++i )
			{
				for( j=0; j < Ny; ++j )
				{
					for( k = 0; k < Nz; ++k )
					{
						a[i][j][k] = i+j+k;
					}
				}
			}
			
			for( i=0; i < Nx; ++i )
			{
				for( j=0; j < Ny; ++j )
				{
					for( k = 0; k < Nz; ++k )
					{
						if( a[i][j][k] != (int)(i+j+k) )
						{
							fprintf( stderr, "3D I/O failure\n");
						}
					}
				}
			}
			
			
		}
		mds_array3d_delete((void ***)a, Nx, Ny, Nz, sizeof(int) );
		MDS_MEMORY();
	}
	
	return 0;
}
